import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const store = new Vuex.Store({  
	state: {
		userAccredit: true,
		userInfo: uni.getStorageSync('userInfo') || {}
	}, 
	mutations: {
		setUserAccredit(state, status) {
			state.userAccredit = status
		},
		setUserInfo(state, data) {
			state.userInfo = Object.assign(state.userInfo, data)
			uni.setStorageSync('userInfo', state.userInfo)
		}
 	},
	actions: {
		setUserInfo:({commit}, data) => {
			commit('setUserInfo', data)
		},
		setUserAccredit:({commit}, status) => {
			commit('setUserAccredit', status)
		}
	}
})

export default store